<?php
class Role {
	
	private $id;
	private $nomRole;
	
	public function Role() {
		$this->id;
		$this->nomRole;
	}
	
	public function getId() {
		return $this->id;
	}
	
	public function getNomRole() {
		return $this->nomRole;
	}
	
	public function setId($id) {
		$this->id = $id;
	}
	
	public function setNomRole($nomRole) {
		$this->nomRole = $nomRole;
	}

	public function getOne($id){
		$connect = new Connect();
		$connect = $connect->findById('roles',$id);
		return $connect;
	}
	
	public function getAll(){
		$connect = new Connect();
		$connect = $connect->findAll('roles');
		return $connect;
	}
	
	public function save($nomRole){
		$connect = new Connect();
		$connect = $connect->insert('roles',array('nomRole' => $nomRole));
		return $connect;
	}
	
	public function update($id,$nomRole){
		$connect = new Connect();
		$connect = $connect->update('roles',$id,array('nomRole' => $nomRole));
		return $connect;
	}
	
	public function delete($id){
		$connect = new Connect();
		$connect = $connect->delete('roles',$id);
		return $connect;
	}
	
	public function getUsers($id){
		$connect = new Connect();
		$connect = $connect->findAll('utilisateurs',array('role_id' => $id));
		return $connect;
	}
}